package com.zb.uniman.algorithm;

import com.zb.uniman.algorithmutils.BaseTransformer;
import com.zb.uniman.algorithmutils.algorithmutils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Author:B
 * Description:
 */
@SpringBootTest
public class test01 {
    /**
     * 生成随机数
     */
    private static int getRandomNumberInRange(int min, int max) {
        Random r = new Random();
        return r.ints(min, (max + 1)).limit(1).findFirst().getAsInt();
    }

    @Test
    public void test01() {
        ArrayList<Integer> arrayList = new ArrayList<>();
        for (int i = 1; i < 20; i++) {
            int number = getRandomNumberInRange(1, 50);
            arrayList.add(number);
        }
        System.out.println("排序之前的list:" + arrayList);
        List list = algorithmutils.sortBypop(arrayList);
        System.out.println("排序之后的list：");
        list.forEach(e -> System.out.println(e));
    }

    @Test
    public void test02() {
        int[] arr = {1, 4, 5, 2, 76, 88};
        List<Integer> list = BaseTransformer.fromarr(arr);
        for (Integer integer : list) {
            System.out.println(integer);
        }


        int[] arr1 = BaseTransformer.toarr(list);
        for (int i = 1; i <= arr1.length; i++) {
            System.out.println(arr1[i - 1]);
        }
    }
}
